package com.zone.gateway.core.executor.result;

/**
 * @author: zongzi
 * @description: 执行器执行结果
 * @date: 2025/4/22
 */
public class SessionResult {
    private final String code;
    private final String name;
    private final Object result;

    public SessionResult(String code,
                         String name,
                         Object result) {
        this.code = code;
        this.name = name;
        this.result = result;
    }

    public static SessionResult success(Object result) {
        return new SessionResult(SessionCode.SUCCESS.getCode(), SessionCode.SUCCESS.getName(), result);
    }

    public static SessionResult fail(Object result) {
        return new SessionResult(SessionCode.FAIL.getCode(), SessionCode.FAIL.getName(), result);
    }

    public static SessionResult newInstant(SessionCode sessionCode, Object result) {
        return new SessionResult(sessionCode.getCode(), sessionCode.getName(), result);
    }


    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public Object getResult() {
        return result;
    }

    @Override
    public String toString() {
        return "GatewayResult{" +
                "code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", result=" + result +
                '}';
    }
}
